<template>
  <div :class="newsListItemImg.container" class="news-list-item">
    <div class="left" :class="{'noimg': !content.content.cover}">
      <div :class="newsListItemImg.title">
        <template v-if="content.content.is_json">
          <router-link :to="{name:'articlePage',params: {id: content.content.msg_id}}" target="_blank">{{content.content.title}}</router-link>
        </template>
        <template v-else>
          <a :href="content.content.source_link" target="_blank">{{content.content.title}}</a>
        </template>
      </div>
      <p>
        {{content.content.summary}}
      </p>
      <p v-if="content.content.summary_2">
        {{content.content.summary_2}}
      </p>
      <p v-if="content.content.subtitle" style="margin-bottom:20px;">
        <span>{{content.content.author}}:&nbsp;&nbsp;</span>{{content.content.subtitle}}
      </p>
      <div :class="newsListItemImg.bottom" class="clearfix">
        <div class="float-left">
          <template v-if="note">
            <span :class="newsListItemImg.note" v-if="content.content.type === 'newproduct'">创投聚合</span>
            <span :class="newsListItemImg.note" v-else-if="content.content.type === 'estp-focus'">新创项目</span>
            <span :class="newsListItemImg.note" v-else-if="content.content.type === 'post'">我的话题</span>
          </template>
          <span :class="newsListItemImg.time">{{content.content.date | time}}</span>
          <span :class="newsListItemImg.source" v-if="content.content.source">{{content.content.source}}</span>
        </div>
        <div class="float-left">
          <template v-if="content.content.msg_id">
            <share :shareId="content.content.msg_id" :title="content.content.title"></share>
          </template>
          <template v-if="content.content.wx_id">
            <span>微信号:&nbsp;{{content.content.wx_id}}</span>
          </template>
        </div>
      </div>
    </div>
    <template v-if="content.content.cover">
      <template v-if="content.content.is_json">
        <router-link :to="{name:'articlePage',params: {id: content.content.msg_id}}" target="_blank" :class="newsListItemImg.right">
          <img :src="content.content.cover" alt="">
        </router-link>
      </template>
      <template v-else>
        <a :href="content.content.source_link" target="_blank" :class="newsListItemImg.right">
          <img :src="content.content.cover" alt="">
        </a>
      </template>
    </template>
  </div>
</template>
<script>
  import share from '../share'
  export default {
    name: 'imgListItem',
    props: {
      note: {
        require: true,
        type: Boolean
      },
      content: {
        require: true
      }
    },
    data () {
      return {}
    },
    components: {
      share
    }
  }
</script>
<style lang="scss">
  .news-list-item{
    .left{
      margin-right:15px;
      width:430px;
      min-height: 90px;
      position: relative;
      >p{
        margin-bottom: 24px;
        /*! autoprefixer: off */
        -webkit-box-orient: vertical;
        /* autoprefixer: on */
        display: -webkit-box;
        -webkit-line-clamp: 2;
        overflow: hidden;
        line-height: 1.3;
        color: #878787;
        font-size: 14px;
        text-overflow: ellipsis;
        min-height: 36px;
      }
      &.noimg{
        width:100%;
      }
    }
  }
</style>
<style lang="scss" module="newsListItemImg">
.container{
  padding: 20px 18px;
  border-bottom: 1px solid #f0f0f0;
  border-right: 1px solid #f0f0f0;
  display: flex;
  justify-content: space-around;
  &:hover{
    background-color: #f6f8fa;
  }
  .right{
    display: flex;
    width: 180px;
    height: 135px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background-size: cover;
    &:hover{
      transform: scale(1.04);
    }
    img{
      max-width:100%;
      max-height: 100%;
    }
  }
  .title{
    color: #33383e;
    max-height: 24px;
    margin-bottom: 8px;
    font-size: 18px;
    display:-webkit-box;
    /*! autoprefixer: off */
    -webkit-box-orient: vertical;
    /* autoprefixer: on */
    overflow: hidden;
    line-height: 24px;
    a{
      overflow : hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      /*! autoprefixer: off */
      -webkit-box-orient: vertical;
      /* autoprefixer: on */
      &:hover{
        color:#3dab85;
      }
      &:visited{
        color: #999;
      }
    }
  }
  .bottom{
    position: absolute;
    width:100%;
    left:0;
    bottom:0;
    font-size: 12px;
    color: #aaa;
    >div:first-child{
      margin-right:10px;
    }
  }
  .note{
    font-size: 12px;
    color: #aaa;
    margin-right:5px;
    &:after{
      content:'';
      display: inline-block;
      width:1px;
      height: 14px;
      background-color: #aaa;
      vertical-align: middle;
      margin-left:10px;
      margin-right: 5px;
    }
  }
  .time{
    font-size: 12px;
    color: #aaa;
  }
  .source{
    display: inline-block;
    font-size: 12px;
    color: #aaa;
    &:before{
      content:'';
      display: inline-block;
      width:1px;
      height: 14px;
      background-color: #aaa;
      vertical-align: middle;
      margin-left:5px;
      margin-right: 10px;
    }
  }
}
</style>
